package com.tianji.aigc.controller;

import java.io.FileOutputStream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.cloud.ai.dashscope.audio.synthesis.SpeechSynthesisResponse;
import com.tianji.aigc.service.AudioService;

import jakarta.annotation.Resource;
import reactor.core.publisher.Flux;

@RequestMapping("audio")
@RestController
public class AudioController {
    Logger logger = LoggerFactory.getLogger(AudioController.class);

    @Resource
    private AudioService audioService;

    @PostMapping("/tts-stream")
    public Flux<SpeechSynthesisResponse> streamTTS(@RequestBody String text) {
        logger.info("开始调用dashscope的tts服务");
        return audioService.streamTTS(text);
    }
}
